package com.winterwar.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.winterwar.base.Table;
import com.winterwar.dao.TableDAO;
import com.winterwar.service.TableManager;

public class TableManagerImpl implements TableManager {

	public Table get(String tableID) {
		Table table = dao.get(Integer.valueOf(tableID));
		if(table == null){
			log.warn("Table with ID " + tableID + " is not present in the database.");
		}
		return table;
	}

	public List getAll() {
		return dao.getAll();
	}

	public void remove(String tableID) {
		dao.remove(Integer.valueOf(tableID));
	}

	public Table save(Table table) {
		dao.save(table);
		return table;
	}

	public void setDAO(TableDAO dao) {
		this.dao = dao;
	}
	
	public List getAllByCon(String conID) {
		return dao.getByConID(Integer.valueOf(conID));
	}

	private TableDAO dao;
	private static Log log = LogFactory.getLog(TableManager.class);

}
